/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	///  好友
	/// module : structs
	/// </summary>
	public class FriendPOD : IPOD 
    {
        public readonly static Func<FriendPOD> FACTORY = () => new FriendPOD();
		public static Func<FriendPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public long id;
		/// <summary>
        ///  玩家GUID
        /// </summary>
		public int guid;
		/// <summary>
        ///  玩家ID
        /// </summary>
		public long pid;
		/// <summary>
        ///  昵称
        /// </summary>
		public string playerName;
		/// <summary>
        ///  头像
        /// </summary>
		public int avatar;
		/// <summary>
        ///  玩家等级
        /// </summary>
		public int level;
		/// <summary>
        ///  是否在线
        /// </summary>
		public bool online;
		/// <summary>
        ///  目标备注
        /// </summary>
		public string remark;
		/// <summary>
        ///  好友类型
        /// </summary>
		public FriendType type;
		/// <summary>
        ///  创建时间
        /// </summary>
		public int createTime;
		/// <summary>
        ///  最后登录时间
        /// </summary>
		public int lastLoginTime;
		/// <summary>
        ///  游戏服务器ID
        /// </summary>
		public string gameServerId;
		/// <summary>
        ///  头像框
        /// </summary>
		public int avatarFrame;
		/// <summary>
        ///  称号
        /// </summary>
		public int title;
		
		
		
		/*-- constructors --*/
		public FriendPOD() {}
		public FriendPOD(long id, int guid, long pid, string playerName, int avatar, int level, bool online, string remark, FriendType type, int createTime, int lastLoginTime, string gameServerId, int avatarFrame, int title) {
			this.id = id;
			this.guid = guid;
			this.pid = pid;
			this.playerName = playerName;
			this.avatar = avatar;
			this.level = level;
			this.online = online;
			this.remark = remark;
			this.type = type;
			this.createTime = createTime;
			this.lastLoginTime = lastLoginTime;
			this.gameServerId = gameServerId;
			this.avatarFrame = avatarFrame;
			this.title = title;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_long(id);
            _out.Write_int(guid);
            _out.Write_long(pid);
            _out.Write_string(playerName);
            _out.Write_int(avatar);
            _out.Write_int(level);
            _out.Write_boolean(online);
            _out.Write_string(remark);
            _out.Write_byte((sbyte)type);
            _out.Write_int(createTime);
            _out.Write_int(lastLoginTime);
            _out.Write_string(gameServerId);
            _out.Write_int(avatarFrame);
            _out.Write_int(title);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            id = _in.Read_long();
            if(!_in.HasRemaining()) return;
            guid = _in.Read_int();
            if(!_in.HasRemaining()) return;
            pid = _in.Read_long();
            if(!_in.HasRemaining()) return;
            playerName = _in.Read_string();
            if(!_in.HasRemaining()) return;
            avatar = _in.Read_int();
            if(!_in.HasRemaining()) return;
            level = _in.Read_int();
            if(!_in.HasRemaining()) return;
            online = _in.Read_boolean();
            if(!_in.HasRemaining()) return;
            remark = _in.Read_string();
            if(!_in.HasRemaining()) return;
            type = (FriendType)_in.Read_byte();
            if(!_in.HasRemaining()) return;
            createTime = _in.Read_int();
            if(!_in.HasRemaining()) return;
            lastLoginTime = _in.Read_int();
            if(!_in.HasRemaining()) return;
            gameServerId = _in.Read_string();
            if(!_in.HasRemaining()) return;
            avatarFrame = _in.Read_int();
            if(!_in.HasRemaining()) return;
            title = _in.Read_int();
        }
		
		public FriendPOD Clone() {
            FriendPOD o = DynamicFactory();
            o.id = id;
            o.guid = guid;
            o.pid = pid;
            o.playerName = playerName;
            o.avatar = avatar;
            o.level = level;
            o.online = online;
            o.remark = remark;
            o.type = type;
            o.createTime = createTime;
            o.lastLoginTime = lastLoginTime;
            o.gameServerId = gameServerId;
            o.avatarFrame = avatarFrame;
            o.title = title;
            return o;
        }
        
        public void Clear() {
            id = default;
            guid = default;
            pid = default;
            playerName = default;
            avatar = default;
            level = default;
            online = default;
            remark = default;
            type = default;
            createTime = default;
            lastLoginTime = default;
            gameServerId = default;
            avatarFrame = default;
            title = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "FriendPOD [";
			str += "id=";
			str += id;
			str += ", guid=";
			str += guid;
			str += ", pid=";
			str += pid;
			str += ", playerName=";
			str += playerName;
			str += ", avatar=";
			str += avatar;
			str += ", level=";
			str += level;
			str += ", online=";
			str += online;
			str += ", remark=";
			str += remark;
			str += ", type=";
			str += type;
			str += ", createTime=";
			str += createTime;
			str += ", lastLoginTime=";
			str += lastLoginTime;
			str += ", gameServerId=";
			str += gameServerId;
			str += ", avatarFrame=";
			str += avatarFrame;
			str += ", title=";
			str += title;
			str += "]";
			return str;
		}
		
	}
}